<% layout('/layout/default.html', {title: '流程模型管理', libs: ['layui']}){ %>
<div class="main-content">
	<div class="card-header">
		<i class="fa fa-sitemap"></i> 流程模型管理
		<div class="header-tools float-right">
			<a href="#" class="btn btn-default btn-sm" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a>
			<% if(hasPermi('act:model:edit')){ %>
			<a href="${ctxStatic}/modler/index.html#/processes" class="btn btn-default btn-sm btnTool"  title="新增流程模型" data-type="layer"><i class="fa fa-plus"></i> 新增</a>
			<% } %>
		</div>
	</div>
	<div class="container-fluid">
		<form id="searchForm" action="${ctx}/act/model/listData" class="form-inline d-none">
			<div class="form-group">
				<label class="control-label">模型标识KEY：</label>
				<div class="control-inline">
					<input name="key" maxlength="100" class="form-control form-control-sm"/>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">模型名称：</label>
				<div class="control-inline">
					<input name="name" maxlength="100" class="form-control form-control-sm"/>
				</div>
			</div>
			<div class="form-group">
				<button type="submit" class="btn btn-success btn-sm ">查询</button>
				<button id="reset" type="reset" class="btn btn-default btn-sm">重置</button>
			</div>
		</form>
		<table id="btGrid"></table>
	</div>
</div>
<% } %>
<script>
//初始化layui-table对象
$('#btGrid').BTGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{title:'模型名称', field:'name'},
		{title:'模型标识KEY', field:'key'},
		{title:'版本号', templet:  function(row){
			return "V:" + row.version;
		}},
		{title:'创建时间', field:'created',templet: function (row) {
			if (row.created){   // data不为空进行转换
				return (new Date(row.created)).Format("yyyy-MM-dd hh:mm:ss");
			} else {
				return ''; //data为空时不转换
			}
		}},
		{title:'最后更新时间', field:'lastUpdated',templet: function (row) {
			if (row.lastUpdated){   // data不为空进行转换
				return (new Date(row.lastUpdated)).Format("yyyy-MM-dd hh:mm:ss");
			} else {
				return ''; //data为空时不转换
			}
		}},
		{title:'操作', width:180, templet: function(row){
			var actions = [];
			<% if(hasPermi('act:model:edit')){ %>
				actions.push('<a href="${ctxStatic}/modler/index.html#/editor/'+row.id+'" class="btn btn-xs btn-success btnList" title="流程模型编辑" data-type="layer"><i class="far fa-edit"></i></a>&nbsp;&nbsp;');
                actions.push('<a href="${ctxStatic}/formdesign/index.html?modelId='+row.id+'&modelKey='+row.key+'&modelVersion='+row.version+'" class="btn btn-xs btn-info btnList" title="表单配置" data-type="layer"><i class="fa fa-fire"></i></a>&nbsp;&nbsp;');
				actions.push('<a href="${ctx}/act/model/deploy?id='+row.id+'" class="btn btn-xs btn-info btnList" title="部署" data-formtitle="流程分类" data-type="form" data-formurl="${ctx}/act/model/choose/category"><i class="fa fa-bolt"></i></a>&nbsp;&nbsp;');
				actions.push('<a href="${flow}/app/rest/models/'+ row.id +'/bpmn20' + '" title="下载" class="btn btn-xs btn-info "><i class="fa fa-download"></i></a>&nbsp;&nbsp;');
				actions.push('<a href="${ctx}/act/model/delete?id='+row.id+'" class="btn btn-xs btn-danger btnList" title="删除" data-confirm="确认要删除该模型吗？"><i class="far fa-trash-alt"></i></a>&nbsp;');

			<% } %>
			
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});

</script>